/*
 * File: GetMessages.java Author: Robert Bittle <guywithnose@gmail.com>
 */
package servlets.admin;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.json.JSONObject;

import faceBook.Message;

/**
 * The Class GetMessages.
 */
public class PostMessage extends HttpServlet
{

  /*
   * (non-Javadoc)
   * 
   * @see
   * javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
   * javax.servlet.http.HttpServletResponse)
   */
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException
  {
    Message message = new Message(Long.valueOf(req.getParameter("id")));
    message.postMessage();
    JSONObject jo = new JSONObject();
    try
    {
      jo.put("confirmation", message.getConfirmations());
    } catch (JSONException e)
    {
      e.printStackTrace();
    }
    resp.getWriter().write(jo.toString());
  }

}
